<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div{
            border: 1px solid black;
        }
        ul{
            display: flex;
            list-style-type: none;
        }
        li{
           margin-left: 25px;
        }
        a{
            display: block;
            text-decoration: none;
            color: black;

        }
        .tab{
            width: 400px;
            height: 300px;
            display: none;
        }
        .show{
            display: block;
        }
        .active{
            color: red;
            border-bottom:1px solid red;
        }
    </style>
</head>
<body>
    <div>
        <ul class="ul">
            <li><a data-id="0" href="#" class="active">one</a></li>
            <li><a data-id="1" href="#">two</a></li>
            <li><a data-id="2" href="#">three</a></li>
            <li><a data-id="3" href="#">four</a></li>
        </ul>
    </div>
   <div class="item">
        <div class="tab show" style="background-color: aqua;"></div>
        <div class="tab" style="background-color: rgb(51, 255, 0);"></div>
        <div class="tab" style="background-color: rgb(33, 9, 49);"></div>
        <div class="tab" style="background-color: rgb(141, 54, 54);"></div>
   </div>
   <script>
       const ul = document.querySelector('.ul')
       ul.addEventListener('mouseover',function(e){
            console.log('enter')
           if (e.target.tagName == 'A'){
               document.querySelector('.active').classList.remove('active')
               e.target.classList.add('active')

               document.querySelector('.tab.show').classList.remove('show')
               let id = +e.target.dataset.id
               document.querySelector(`.item .tab:nth-child(${id+1})`).classList.add('show')

           }
       })

   </script>
</body>
</html>
